package com.liuhx.mapper.sql;

import com.liuhx.entity.BrandEntity;
import com.liuhx.entity.CityEntity;

import java.text.MessageFormat;
import java.util.List;
import java.util.Map;

/**
 * Created by liuhx on 2017/7/13.
 */
public class BrandSql {
    public String insertBrands(Map map)
    {
        List<BrandEntity> brandEntityList = (List<BrandEntity>) map.get("list");
        StringBuilder sb = new StringBuilder();
        sb.append("INSERT INTO brand_info ");
        sb.append("(brandName, brandUrl) ");
        sb.append("VALUES ");
        MessageFormat mf = new MessageFormat("( #'{'list[{0}].brandName}, #'{'list[{0}].brandUrl})");
        for (int i = 0; i < brandEntityList.size(); i++) {
            sb.append(mf.format(new Object[]{i}));
            if (i < brandEntityList.size() - 1) {
                sb.append(",");
            }
        }
        return sb.toString();
    }
}
